package cn.me.alphamq.broker.enumeration;

/**
 * 消费者与队列重平衡策略的枚举类
 *
 * @author f
 */
public enum RebalanceStrategyEnum {
    ROUND_ROBIN("round_robin", "轮询策略"),
    RANDOM("random", "随机策略");

    // 根据枚举的 code 属性获取枚举
    public static RebalanceStrategyEnum of(String code) {
        for (RebalanceStrategyEnum strategy : RebalanceStrategyEnum.values()) {
            if (strategy.code.equals(code)) {
                return strategy;
            }
        }
        throw new RuntimeException("invalid rebalance strategy code: " + code);
    }

    private final String code;
    private final String desc;

    RebalanceStrategyEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
